package com.wenhai.spring.bean.lifecycle;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.context.annotation.AnnotatedBeanDefinitionReader;
import org.springframework.context.annotation.Bean;

/**
 * @Author:wenhai
 * @Description: 注解BeanDefinitionParser示例
 * @Date:2020/3/16
 */
public class AnnotatedBeanDefinitionParserDemo {
    public static void main(String[] args) {
        DefaultListableBeanFactory context = new DefaultListableBeanFactory();
        AnnotatedBeanDefinitionReader reader = new AnnotatedBeanDefinitionReader(context);
        int beanDefinitionCount = context.getBeanDefinitionCount();
        System.out.println(beanDefinitionCount);
        reader.registerBean(AnnotatedBeanDefinitionParserDemo.class);
        beanDefinitionCount = context.getBeanDefinitionCount();
        System.out.println(beanDefinitionCount);

        System.out.println(context.getBean(SingletonBean.class));
    }


    @Bean
    public SingletonBean createSingletonBean() {
        return new SingletonBean();
    }
}
